#include "cpp_story.h"
#include <stdio.h>
#include <iostream>

struct Context
{
    int i;
    double d;
    double result;
    std::string s;
};

STEP_DEF("int value (.*)")
{
    CONTEXT(Context, c);
    REGEX_INT(i);
    c->i = i;
    return true;
}

STEP_DEF("double value (.*)")
{
    CONTEXT(Context, c);
    REGEX_DOUBLE(d);
    c->d = d;
    return true;
}

STEP_DEF("string value (.*)")
{
    CONTEXT(Context, c);
    REGEX_STRING(s);
    c->s = s;
    return true;
}

STEP_DEF("add values of int and double")
{
    CONTEXT(Context, c);
    c->result = c->d + c->i;
    return true;
}

STEP_DEF("add result is equal to string value")
{
    CONTEXT(Context, c);
    char str[16] = {0};
    sprintf(str, "%.1f", c->result);
    std::string s = str;

    CHECK_EQUAL(s, c->s);
    return true;
}

